﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure;

namespace EncryptDecrypt
{
    public class SymmetricKeyDataServiceContext: TableServiceContext
    {
        public SymmetricKeyDataServiceContext(string baseAddress, StorageCredentials credentials)
            : base(baseAddress, credentials)
        {

        }


        public IQueryable<SymmetricKey> SymmetricKeys
        {
            get
            {
                return this.CreateQuery<SymmetricKey>("SymmetricKeys");
            }
        }

       

        public SymmetricKey SaveSymmetricKey(SymmetricKey sKey)
        {
            // Todo: Next version: add retry logic here to increment the version number if needed...

            this.AddObject("SymmetricKeys", sKey);
            this.SaveChanges();

            // Return the skey in case the version number changed due to conflict
            return sKey;
        }
    }

}
